package com.huatai.exchange.impl;

import com.faneui.common.exception.BusinessException;
import com.huatai.exchange.dal.dao.*;
import com.huatai.exchange.dal.model.*;
import com.huatai.exchange.service.ExcDataFileInfoService;
import com.huatai.exchange.service.ExcuteExchangeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

@Service
public class ExcDataFileInfoServiceImpl implements ExcDataFileInfoService {

    private static final Logger logger = LoggerFactory.getLogger(ExcuteExchangeService.class);

    @Autowired
    private ExcDataFileInfoDAO excDataFileInfoDAO;

    @Override
    public List<ExcDataFileInfo> queryExcDataFileInfoList(ExcDataFileInfo excDataFileInfo) throws BusinessException {
        List<ExcDataFileInfo> excDataFileInfos = null;
        try {
            excDataFileInfos = excDataFileInfoDAO.queryByModel(excDataFileInfo) ;
        } catch (Exception ex) {
            BusinessException.throwBusinessException(ex);
        }
        return excDataFileInfos;
    }


    @Override
    public void addExcDataFileInfo(ExcDataFileInfo excDataFileInfo) throws BusinessException {
        try {
            excDataFileInfoDAO.insert(excDataFileInfo);
        } catch (Exception ex) {
            BusinessException.throwBusinessException(ex);
        }
    }

    @Override
    public void modifyExcDataFileInfo(ExcDataFileInfo excDataFileInfo) throws BusinessException {
        try {
            Long num = excDataFileInfoDAO.updateById(excDataFileInfo);
            if (num == 0) {
                throw new BusinessException("更新失败") ;
            }
        } catch (Exception ex) {
            BusinessException.throwBusinessException(ex);
        }
    }

    @Override
    public void deleteExcDataFileInfo(String id) throws BusinessException {
        try {
            Long num = excDataFileInfoDAO.deleteById(id) ;
            if (num == 0) {
                throw new BusinessException("删除失败") ;
            }
        } catch (Exception ex) {
            BusinessException.throwBusinessException(ex);
        }
    }

    @Override
    public ExcDataFileInfo queryExcDataFileInfo(String id) throws BusinessException {
        ExcDataFileInfo excDataFileInfo = null;
        try {
            excDataFileInfo = excDataFileInfoDAO.queryById(id) ;
        } catch (Exception ex) {
            BusinessException.throwBusinessException(ex);
        }
        return excDataFileInfo ;
    }
}
